﻿<!doctype html>

<html>

<head>
    <meta charset="utf-8">
    <title>就诊人信息</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weui.css" />
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weuix.css" />
    <link href="/customer/css/blue.css" rel="stylesheet" />
    <script src="/lobsteruiframe/weui/js/zepto.min.js"></script>
    <script src="/lobsteruiframe/weui/js/zepto.weui.js"></script>
    <script src="/lobsteruiframe/weui/js/php.js"></script>
    <script src="/jslib/template-web.js"></script>
    <script src="/jslib/lobster.js"></script>
    <style type="text/css">
        .tipsTitile {
            /* background-color: #e0ecfa;*/
            color: #CCCCCC;
            padding: 16px;
            font-size: 17px;
        }

        .blue-rt {
            color: gray;
        }

        .blue-blt-title {
            border-bottom: 0.5px #e8e8e8 solid;
            padding: 0px 15px;
            font-size: 17px;
            line-height: 45px;
            position: relative;
        }
    </style>

</head>

<body ontouchstart>
    <div class="maincontent" id="maincontent">
        <div class='pageContent'>
            <div class="tipsTitile bg-gray">温馨提示：绑定就诊人后身份信息不能更改</div>
            <!--标题-->
            <div class="blue_ensure_order">
                <!--<div class="blue-public-title-one" style="border-bottom:1px #f5f5f5 solid">个人信息</div>-->
                <div class="weui-panel__hd">个人信息</div>
                <div class="blue_eo_context" id="patientdata">

                </div>
            </div>
            <div class="weui-panel__hd" id="cardNum">诊疗卡(0张)</div>
            <!--<div class="blue-public-title-one blue-bb" style="font-size:17px" id="cardNum">诊疗卡(0张)</div>-->
            <div id="cardlist">

            </div>
        </div>
    </div>
</body>
</html>
<script>

    lobsterh5.main({
        data: {
        },
        //初始化页面
        pageload: function () {
            this.initevent();

            var patientId = lobsterh5.GetUrlParam("patientId");
            this.getdata(patientId);
        },
        //初始化事件
        initevent: function () {
            var self = this;

            //$(document).on("click", ".blue-blt-title", function (obj) {
            //    var cardinfo = obj.currentTarget.dataset.card;
            //    lobsterh5.SetPageStorage("patient", cardinfo);
            //    location.href = "bindcard.html";
            //    console.log(obj);
            //})
        },
        getdata: function (patientId) {
            var self = this;

            lobsterh5.GET("/admin/v1/CPatient/GetPatienInfo", { patientId: patientId}).then(res => {
                console.log(res);
                var patient = res.patInfo;
                var cardList = res.cardList || [];
                var cardTypeList = res.cardTypeList || [];
                if (cardList && cardList.length > 0)
                    $("#cardNum").html("诊疗卡(" + cardList.length + "张)");
                self.showdata(patient[0], cardList, cardTypeList, patientId);
            });
        },
        showdata: function (patient, cardList, cardTypeList) {
            var self = this;
            var list = [];

            self.inittemp("patientinfo", "patientdata", patient);
            cardTypeList.forEach(function (item, index, items) {
                item.items = item.BusinessText.split(",");
                item.showCardNo = item.CardNo;
                var codeModel = cardList.filter((x, index, arr) => {
                    return x.Code == item.Code
                });
                if (codeModel && codeModel.length > 0) {
                    item.CardNo = codeModel[0].CardNo;
                    item.CardId = codeModel[0].CardId;
                    item.IsDefault = codeModel[0].IsDefault;
                    item.PatientId = patient.PatientId;
                    list.push(item);
                }
            });
            self.inittemp("tplcard", "cardlist", { list: list });
        },
        inittemp: function (tempid, _id, data) {
            var html = template(tempid, data);
            $("#" + _id).html(html);
        }
    });

</script>

<script type="text/template" id="tplcard">
    {{each list}}
    <div class="blue-blt-title" data-card="{{$value}}">
        <div class="blue-lt" style="display:flex">
            <text> {{$value.Name}}</text>
            {{if($value.BusinessText)}}
            <div class="orange-color" style="padding-left:5px">{{$value.BusinessText}}</div>
            {{/if}}
            {{if($value.IsDefault==1)}}
            <div class="blue-color" style="margin-left:5px">默认</div>
            {{/if}}
        </div>
        <div class="blue-rt blue-mr ">
            <text> {{$value.CardNo}}</text>
        </div>

        <div class="clearfix"></div>
    </div>
    {{/each}}
</script>

<script type="text/template" id="patientinfo">

    <div class="blue_eo_details">
        <div class="blue_eod_one">姓名：</div>
        <div class="blue_eod_two">{{Name}}</div>
    </div>
    <div class="blue_eo_details">
        <div class="blue_eod_one">证件类型：</div>
        <div class="blue_eod_two">{{CardTypeName}}</div>
    </div>
    <div class="blue_eo_details">
        <div class="blue_eod_one">证件号码：</div>
        <div class="blue_eod_two">{{cardNo}}</div>
    </div>
    <div class="blue_eo_details">
        <div class="blue_eod_one">出生日期：</div>
        <div class="blue_eod_two">{{Birthday}}</div>
    </div>
    <div class="blue_eo_details">
        <div class="blue_eod_one">手机号码：</div>
        <div class="blue_eod_two">{{Phone}}</div>
    </div>

</script>
